<%@ page pageEncoding="UTF-8"%>

<%@ page import="java.io.*"%>
<%
  String contentType = request.getContentType();
    String saveFile ="";
  if ((contentType != null) && (contentType.indexOf("multipart/form-data") >= 0)) {
    DataInputStream in = new DataInputStream(request.getInputStream());
    int formDataLength = request.getContentLength();
    byte dataBytes[] = new byte[formDataLength];
    int byteRead = 0;
    int totalBytesRead = 0;
    while (totalBytesRead < formDataLength) {
      byteRead = in.read(dataBytes, totalBytesRead, formDataLength);
      totalBytesRead += byteRead;
    }
    String file = new String(dataBytes);
    saveFile = file.substring(file.indexOf("filename=\"") + 10);
    saveFile = saveFile.substring(0, saveFile.indexOf("\n"));
    saveFile = saveFile.substring(saveFile.lastIndexOf("\\") + 1, saveFile.indexOf("\""));
    System.out.println(saveFile);
    int lastIndex = contentType.lastIndexOf("=");
    String boundary = contentType.substring(lastIndex + 1, contentType.length());
    int pos;
    pos = file.indexOf("filename=\"");
    pos = file.indexOf("\n", pos) + 1;
    pos = file.indexOf("\n", pos) + 1;
    pos = file.indexOf("\n", pos) + 1;
    int boundaryLocation = file.indexOf(boundary, pos) - 4;
    int startPos = ((file.substring(0, pos)).getBytes()).length;
    int endPos = ((file.substring(0, boundaryLocation)).getBytes()).length;
    // creating a new file with the same name and writing the content in new file
    FileOutputStream fileOut = new FileOutputStream(saveFile);
    fileOut.write(dataBytes, startPos, (endPos - startPos));
    fileOut.flush();
    fileOut.close();
  }
%>
<%@include file="inc-header.jsp"%>
<div class="main">
	<div class="item mag0">
		<%@include file="inc-menu.jsp"%>
		<div class="portlet" id="yw0">
			<%@include file="inc_userinfo.jsp"%>
		</div>
		<!-- end box login -->
		<div class="item revenue mag0">
			<table border="2">
				<tr>
					<td>
						<b>You have successfully upload the file by the name of:</b>
						<%
						  out.println(saveFile);
						%>
					</td>
				</tr>
			</table>
			<div class="bg_gray2">
				<span class="s18 cl006fbc"><strong class="sms-paym">Gắn
						thanh toán SMS</strong> </span>
			</div>

		</div>

		<div class="list-game mag-t10">
			<ul class="list_style">
				<li>
					<div class="style_tab relative">
						<span class="absolute">Kết quả</span>
					</div>
					<div class="box-style adcard-pay">
						<p>
							<span>Html code:</span>
							<br>
							<textarea style="width: 99%; height: 30px; text-align: left">
							 &lt;a href="http://bit.ly/14orlQu" rel="nofollow" &gt;ZhuShen_YN_seU908E.jar&lt;/a&gt;
							 </textarea>
						</p>
						<p></p>
						<div class="file-download mag-btt10">
							<p>
								Download:
							</p>

							<p>
								<a class="ic-downl" href="http://bit.ly/14orlQu">ZhuShen_YN_seU908E.jar</a>
							</p>
						</div>
						<div class="err_log txt-left mag-btt10">
							<strong class="s16 clred">Chú ý!!!</strong>
							<p>
								Nên kiểm tra lại file sau khi sau khi gắn thanh toán SMS để đảm
								bảo hoạt động tốt
							</p>
							<p>
								<a class="cl333" href="./upfile_files/upfile.htm"><strong>Download</strong>
									giả lập mobile để test Game/Ứng Dụng</a>
							</p>
							<p>
								Nếu có lỗi xảy ra vui lòng báo lỗi cho admin
							</p>
						</div>
					</div>
				</li>

			</ul>
			<div class="pad-l10 clearfix">
				<div class="img-orage fl clearfix">

					<input type="button" onclick="" class="r-img-orage" value="Tạo mới">
				</div>
				<span class="btn-regis"><a onclick="history.go(-1)" href="">Quay
						lại</a> </span>
			</div>
		</div>

		<div class="portlet" id="yw1">
			<div class="portlet-content">
				<p class="mag0 link-top">
				</p>

				<%@include file="inc-footter.jsp"%>